<template>
  <div class="home"> 
    <el-table
      :data="tableData"
      style="width: 1000px">
      <el-table-column
        prop="name"
        label="姓名"
        width="180">
      </el-table-column>
      <el-table-column
        prop="age"
        label="年龄"
        width="180">
      </el-table-column>
      <el-table-column
        label="头像">
        <template slot-scope="scope">
          <img :src="scope.row.image" alt="" width="50">
        </template>
      </el-table-column>
      <el-table-column
        label="年龄"
        width="180">
        <template slot-scope="scope">
          {{scope.row.gender == 1?"男": "女"}}
        </template>
      </el-table-column>
      <el-table-column
        label="职业"
        width="180">
        <template slot-scope="scope">
          {{jobMapping[scope.row.job - 1]}}
        </template>
      </el-table-column>
    </el-table> 
  </div>
</template>
<script>
export default {
  name: 'HomeView',
  data() {
    return {
      tableData: [], 
      jobMapping: [
        "讲师", "班主任", "就业指导"
      ]
    }
  }, 
  methods: {
    async javaTest() {
      try{
        const { data: res } = await this.$api.testJava1();
        console.log(res);
        if(res.code == 1) {
          this.tableData = res.data
        }
        
      } catch(err) {
        console.log(err);
      }
    }
  },
  created() {
    this.javaTest(1);
  }
}
</script>
